package com.happy.seatwork;

import java.util.Scanner;

public class grass_boat02 {
    public static void main(String args[])
    {
        int sum, grass = 20, boat = 16;
        int grass_life = 30, boat_life = 20;
        int num1, num2 = 0, sum_life = 0;
        int best_num1 = 0, best_num2 = 0;
        Scanner scanner = new Scanner (System.in);
        System.out.println("请输入您的金币数量：");
        sum = (scanner.nextInt());
        for (num1 = 0; num1 < sum / grass; num1++)
        {
            num2 = (sum - num1 * grass) / boat;
            int current = num1 * grass_life + num2 * boat_life;
            if (current >= sum_life) {
                sum_life = current;
                best_num1 = num1;
                best_num2 = num2;
            }
        }
        System.out.printf("仙女草购买数量为%d个，银河梭购买数量为%d个，增加的生命力为%d", best_num1, best_num2, sum_life);
    }
}
